Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unordered_map for attr handler #805

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

coco875
Copy link
Contributor

@coco875 coco875 commented Jan 29, 2025

change ucode_attr_handlers to an array of array instead of map to no longer compute hash.

@briaguya-ai
Copy link
Collaborator

could you please provide a PR description? i know there were discussions about the performance implications of this change, it'd be good to have those documented as part of this PR

const auto ucode_map = ucode_attr_handlers[ucode_handler_index];
assert(ucode_map->contains(attr) && "Attribute not found in the current ucode handler");
return std::any_cast<T>(ucode_map->at(attr));
// assert(ucode_map->contains(attr) && "Attribute not found in the current ucode handler");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ucode_map are no longer a map so we no longer need to do the assert.

@coco875
Copy link
Contributor Author

coco875 commented Feb 21, 2025

i know there were discussions about the performance implications of this change, it'd be good to have those documented as part of this PR

what do you mean by document it ? because it's just change an unordored_map<int, int> where the key are an enum with limited range and static so I just change it to use instead an array so not so much change.

@briaguya-ai
Copy link
Collaborator

what do you mean by document it ?

the what aspect of this PR is clear, but the why is not documented.

i remember conversations about the why relating to performance. it'd be good to document performance gains from this change and weigh them against the original reasoning behind the architectural decision to use a map (it looks like these maps were added in #557 and updated in #567 - @KiritoDv do you have thoughts on this one?)

@coco875
Copy link
Contributor Author

coco875 commented Feb 21, 2025

originally it use an unordered_map because @KiritoDv want just to make it work, without really caring about performance, by changing to just an array to allow to access more directly to the ressource (so avoid all process of an hash table). I will ping you in the private channel where we discuss about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants